package com.qiantu.phone.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.hjq.widget.view.SwitchButton;
import com.qiantu.api.entity.LinkageBean;
import com.qiantu.api.entity.MusicListBean;
import com.qiantu.phone.R;
import com.qiantu.phone.app.AppAdapter;
import com.qiantu.phone.glide.GlideApp;

import java.util.List;

public class MusicSearchAdapter extends AppAdapter<MusicListBean.MiguMusicDtos> {
    public MusicSearchAdapter(@NonNull Context context) {
        super(context);
    }

    @NonNull
    @Override
    public MusicSearchAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MusicSearchAdapter.ViewHolder();
    }
    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ImageView musicIcon;
        private TextView musicName;
        private TextView singerName;

        private ViewHolder() {
            super(R.layout.item_music_search);
            musicIcon = findViewById(R.id.music_icon);
            musicName = findViewById(R.id.music_name);
            singerName = findViewById(R.id.singer_name);
        }

        @Override
        public void onBindView(int position) {
            MusicListBean.MiguMusicDtos musicDtos = getItem(position);
            GlideApp.with(musicIcon).load(musicDtos.getPicURL()).into(musicIcon);
            musicName.setText(musicDtos.getMusicName());
            singerName.setText(musicDtos.getSingerName());
        }
    }

    @Override
    public long getItemId(int position) {
        return getData().get(position).hashCode();
    }
}
